home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / include / Xm / TextOutP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-30  |  13.8 KB  |  446 lines

  1. /* 
  2.  * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC. 
  3.  * ALL RIGHTS RESERVED 
  4. */ 
  5. /* 
  6.  * Motif Release 1.2.2
  7. */ 
  8. /*   $RCSfile: TextOutP.h,v $ $Revision: 10.1 $ $Date: 1994/02/03 15:52:43 $ */
  9. /*
  10. *  (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
  11. /*
  12. *  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 HEWLETT-PACKARD COMPANY */
  13. #ifndef _XmTextOutP_h
  14. #define _XmTextOutP_h
  15.  
  16. #include <Xm/XmP.h>
  17. #include <Xm/Text.h>
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. /****************************************************************
  24.  *
  25.  * Definitions for modules implementing and using text output routines.
  26.  *
  27.  ****************************************************************/
  28.  
  29. #define ShouldWordWrap(data, widget)    (data->wordwrap && \
  30.        (!(data->scrollhorizontal && \
  31.        (XtClass(widget->core.parent) == xmScrolledWindowWidgetClass))) \
  32.        && widget->text.edit_mode != XmSINGLE_LINE_EDIT && !data->resizewidth)
  33.  
  34. typedef struct _LineTableExtraRec {
  35.     Dimension width;
  36.     Boolean wrappedbychar;
  37. } LineTableExtraRec, *LineTableExtra ;
  38.  
  39. /*         
  40.  * output.c  (part of stext)
  41.  */
  42.  
  43. typedef unsigned int LineNum;
  44. typedef enum {on, off} OnOrOff;    /* For when Booleans aren't obvious enough. */
  45.  
  46. /*
  47.  * Return the line number containing the given position.  If text currently
  48.  * knows of no line containing that position, returns NOLINE.
  49.  */
  50.  
  51. #define NOLINE    30000
  52.  
  53. /*
  54.  * These next define the types of the routines that output is required
  55.  * to export for use by text and by input.
  56.  */
  57.  
  58. typedef struct _OutputDataRec {
  59.     XmFontList fontlist;    /* Fontlist for text. */
  60.     unsigned int blinkrate;
  61.     Boolean wordwrap;        /* Whether to wordwrap. */
  62.     Boolean cursor_position_visible;
  63.     Boolean autoshowinsertpoint;
  64.     Boolean hasfocus;
  65.     Boolean has_rect;
  66.     Boolean handlingexposures;    /* TRUE if in the midst of expose events. */
  67.     Boolean exposevscroll;    /* Non-zero if we expect expose events to be
  68.                    off vertically. */
  69.     Boolean exposehscroll;    /* Non-zero if we expect expose events to be
  70.                    off horizontally. */
  71.     Boolean resizewidth, resizeheight;
  72.     Boolean scrollvertical, scrollhorizontal;
  73.     Boolean scrollleftside, scrolltopside;
  74.     Boolean ignorevbar;        /* Whether to ignore callbacks from vbar. */
  75.     Boolean ignorehbar;        /* Whether to ignore callbacks from hbar. */
  76.     short int cursor_on;        /* Whether IBeam cursor is visible. */
  77.     Boolean refresh_ibeam_off;    /* Indicates whether area under IBeam needs
  78.                  * to be re-captured */
  79.     Boolean suspend_hoffset;    /* temporarily suspend horizontal scrolling */
  80.     Boolean use_fontset;        /* True if font to be used is fontset (and
  81.                  * thus need X11R5 Xmb* routines to draw */
  82.     Boolean have_inverted_image_gc; /* fg/bg of image gc have been swapped;
  83.                      * on == True, off == False */
  84.     OnOrOff blinkstate;
  85.     Position insertx, inserty;
  86.     int number_lines;        /* Number of lines that fit in the window. */
  87.     int leftmargin, rightmargin;
  88.     int topmargin, bottommargin;
  89.     int scrollwidth;        /* Total width of text we have to display. */
  90.     int vsliderSize;        /* How big the thumb is in the vbar. */
  91.     int hoffset;        /* How much we've scrolled off the left. */
  92.     int averagecharwidth;    /* Number of pixels for an "average" char. */
  93.     int tabwidth;        /* Number of pixels for a tab. */
  94.     short columns, rows;
  95.     Dimension lineheight;    /* Number of pixels per line. */
  96.     Dimension minwidth, minheight;
  97.     Dimension prevW;
  98.     Dimension prevH;
  99.     Dimension cursorwidth, cursorheight;
  100.     Dimension font_ascent;      /* ascent of the font[set] */
  101.     Dimension font_descent;     /* descent of the font[set] */
  102.     XtIntervalId timerid;
  103.     Pixmap cursor;        /* Pixmap for IBeam cursor stencil. */
  104.     Pixmap add_mode_cursor;    /* Pixmap to use for add mode cursor. */
  105.     Pixmap ibeam_off;        /* Pixmap for area under the IBeam. */
  106.     Pixmap stipple_tile;    /* stiiple for add mode cursor. */
  107.     GC gc, imagegc;
  108.     Widget vbar, hbar;
  109.     XFontStruct *font;        /* font used when NULL font is set. */
  110. /* New for 1.2 */
  111.     GC save_gc;                 /* GC for saving/resotring under IBeam */
  112.     short columns_set, rows_set; /* history of previously set dimensions */
  113. } OutputDataRec, *OutputData;
  114.  
  115.  
  116. /*
  117.  * Create a new instance of an output object.  This is expected to fill in
  118.  * info about innerwidget and output in the widget record.
  119.  */
  120.  
  121. #ifdef _NO_PROTO
  122. typedef void (*OutputCreateProc)();
  123. #else
  124. typedef void (*OutputCreateProc)(
  125.             Widget,
  126.             ArgList,
  127.             Cardinal) ;
  128. #endif
  129. /*
  130.  * Given an (x,y) coordinate, return the closest corresponding position. (For
  131.  * use by input; text shouldn't ever need to know.)
  132.  */
  133.  
  134. #ifdef _NO_PROTO
  135. typedef XmTextPosition (*XYToPosProc)(); /* ctx, x, y */
  136. #else
  137. typedef XmTextPosition (*XYToPosProc)(
  138.             XmTextWidget,
  139. #if NeedWidePrototypes
  140.             int,
  141.             int) ;
  142. #else
  143.             Position,    /* These are relative to the */
  144.             Position) ;    /* innerwindow returned above. */
  145. #endif
  146. #endif
  147.  
  148. /*
  149.  * Return the (x,y) coordinate corresponing to the given position.  If this
  150.  * returns FALSE, then the given position isn't being displayed.
  151.  */
  152.  
  153. #ifdef _NO_PROTO
  154. typedef Boolean (*PosToXYProc)(); /* widget, position, x, y */
  155. #else
  156. typedef Boolean (*PosToXYProc)(
  157.             XmTextWidget,
  158.             XmTextPosition,
  159.             Position *,    /* These are relative to the */
  160.             Position *) ;    /* innerwindow returned above. */
  161. #endif
  162.  
  163. /*
  164.  * Measures the extent of a line.  Given the line number and starting position
  165.  * of a line, returns the starting position of the next line.  Also returns
  166.  * any extra information that the output module may want to associate with
  167.  * this line for future reference.  (In particular, it will want to associate
  168.  * a vertical coordinate for this line.)  This routine should return FALSE if
  169.  * it decides that this line will not fit in the window.  FALSE should never
  170.  * be returned if the line number is zero.  Output may assume that the line
  171.  * table for all preceeding lines have already been set.  In particular, when
  172.  * this routine will return FALSE, then output knows that the entire linetable
  173.  * has been calculated; that is a good time for it to look over the linetable
  174.  * and decide if it wants to do something obnoxious like resize the window.
  175.  *
  176.  * A possible value to put in nextpos is PASTENDPOS.  This indicates that the
  177.  * current line contains the end of the text in the source.
  178.  *
  179.  * nextpos may be NULL.  If it is, then this indicates that we only want to
  180.  * know if the line will fit on the window.  The caller already has its own
  181.  * idea where the next line will start if it does fit.  (If nextpos is NULL,
  182.  * then no extra information should be generated, and the 'extra' parameter
  183.  * should be ignored.)
  184.  */
  185.  
  186. #define PASTENDPOS    2147483647  /* Biggest number that can fit in long */
  187.  
  188. #ifdef _NO_PROTO
  189. typedef Boolean (*MeasureLineProc)(); /* ctx, line, pos, nextpos, extra */
  190. #else
  191. typedef Boolean (*MeasureLineProc)(
  192.             XmTextWidget,
  193.             LineNum,
  194.             XmTextPosition,
  195.             XmTextPosition *,
  196.             LineTableExtraRec **) ;
  197. #endif
  198.  
  199. /*
  200.  * Draw some text within a line.  The output finds out information about the
  201.  * line by calling the line table routines.
  202.  *
  203.  * %%% Document special cases (like lines containing PASTENDPOS).
  204.  */
  205.  
  206. #ifdef _NO_PROTO
  207. typedef void (*DrawProc)();    /* ctx, line, start, end, highlight */
  208. #else
  209. typedef void (*DrawProc)(
  210.             XmTextWidget,
  211.             LineNum,
  212.             XmTextPosition,
  213.             XmTextPosition,
  214.             XmHighlightMode) ;
  215. #endif
  216.  
  217. /*
  218.  * Output should draw or erase an insertion point at the given position.
  219.  */
  220.  
  221. #ifdef _NO_PROTO
  222. typedef void (*DrawInsertionPointProc)(); /* ctx, position, onoroff */
  223. #else
  224. typedef void (*DrawInsertionPointProc)(
  225.             XmTextWidget,
  226.             XmTextPosition,
  227.             OnOrOff) ;
  228. #endif
  229.  
  230. /*
  231.  * Output should ensure that the given position is visible (e.g., not scrolled
  232.  * off horizontally).
  233.  */
  234. #ifdef _NO_PROTO
  235. typedef void (*MakePositionVisibleProc)();    /* widget, position */
  236. #else
  237. typedef void (*MakePositionVisibleProc)(
  238.             XmTextWidget,
  239.             XmTextPosition) ;
  240. #endif
  241.  
  242. /* Text would like to move some lines around on the screen.  It would like to
  243.  * move lines fromline through toline (inclusive) to now start at line
  244.  * destline.  If output can perform this move by means of a XCopyArea or
  245.  * similar simple call, it does so and returns TRUE; otherwise, it will return
  246.  * FALSE.  If TRUE, output should modify affected values in the
  247.  * "extra" entries in the linetable, because after returning text will go ahead
  248.  * and move linetable entries around.
  249.  */
  250.  
  251. #ifdef _NO_PROTO
  252. typedef Boolean (*MoveLinesProc)(); /* ctx, fromline, toline, destline */
  253. #else
  254. typedef Boolean (*MoveLinesProc)(
  255.             XmTextWidget,
  256.             LineNum,
  257.             LineNum,
  258.             LineNum) ;
  259. #endif
  260.  
  261. /*
  262.  * Inform output of invalidated positions.
  263.  */
  264.  
  265. #ifdef _NO_PROTO
  266. typedef void (*InvalidateProc)(); /* ctx, position, topos, delta */
  267. #else
  268. typedef void (*InvalidateProc)(
  269.             XmTextWidget,
  270.             XmTextPosition,
  271.             XmTextPosition,
  272.             long) ;
  273. #endif
  274.  
  275. /*
  276.  * Get preferred size of text widget based on the row and column
  277.  * resources multiplied by font attributes as well as adding the
  278.  * margin resource values to the computed size.
  279.  */
  280. #ifdef _NO_PROTO
  281. typedef void (*GetPreferredSizeProc)(); /* widget, width, height */
  282. #else
  283. typedef void (*GetPreferredSizeProc)(
  284.             Widget,
  285.             Dimension *,
  286.             Dimension *) ;
  287. #endif
  288.  
  289. /*
  290.  * Get values out of the output object.
  291.  */
  292.  
  293. #ifdef _NO_PROTO
  294. typedef void (*GetValuesProc)(); /* widget, args, num_args */
  295. #else
  296. typedef void (*GetValuesProc)(
  297.             Widget,
  298.             ArgList,
  299.             Cardinal) ;
  300. #endif
  301.  
  302. /*
  303.  * Set values in the output object.
  304.  */
  305.  
  306. #ifdef _NO_PROTO
  307. typedef Boolean (*SetValuesProc)(); /* oldw, reqw, new_w, args, num_args */
  308. #else
  309. typedef Boolean (*SetValuesProc)(
  310.             Widget,
  311.             Widget,
  312.             Widget,
  313.             ArgList,
  314.             Cardinal *) ;
  315. #endif
  316.  
  317.  
  318. typedef struct _OutputRec {
  319.     struct _OutputDataRec    *data; /* Output-specific data; opaque type. */
  320.     XYToPosProc            XYToPos;
  321.     PosToXYProc            PosToXY;
  322.     MeasureLineProc        MeasureLine;
  323.     DrawProc            Draw;
  324.     DrawInsertionPointProc    DrawInsertionPoint;
  325.     MakePositionVisibleProc    MakePositionVisible;
  326.     MoveLinesProc        MoveLines;
  327.     InvalidateProc        Invalidate;
  328.     GetPreferredSizeProc    GetPreferredSize;
  329.     GetValuesProc        GetValues;
  330.     SetValuesProc        SetValues;
  331.     XmRealizeOutProc        realize;
  332.     XtWidgetProc        destroy;
  333.     XmResizeFlagProc        resize;
  334.     XtExposeProc        expose;
  335. } OutputRec;
  336.  
  337.  
  338. /********    Private Function Declarations    ********/
  339. #ifdef _NO_PROTO
  340.  
  341. extern void _XmTextFreeContextData() ;
  342. extern void _XmTextResetClipOrigin() ;
  343. extern void _XmTextAdjustGC() ;
  344. extern Boolean _XmTextShouldWordWrap() ;
  345. extern Boolean _XmTextScrollable() ;
  346. extern XmTextPosition _XmTextFindLineEnd() ;
  347. extern void _XmTextOutputGetSecResData() ;
  348. extern int _XmTextGetNumberLines() ;
  349. extern void _XmTextMovingCursorPosition() ;
  350. extern void _XmTextDrawDestination() ;
  351. extern void _XmTextClearDestination() ;
  352. extern void _XmTextDestinationVisible() ;
  353. extern void _XmTextChangeBlinkBehavior() ;
  354. extern void _XmTextOutputCreate() ;
  355. extern Boolean _XmTextGetBaselines() ;
  356. extern Boolean _XmTextGetDisplayRect() ;
  357. extern void _XmTextMarginsProc() ;
  358. extern void _XmTextChangeHOffset() ;
  359. extern void _XmTextToggleCursorGC() ;
  360.  
  361. #else
  362.  
  363. extern void _XmTextFreeContextData( 
  364.                         Widget w,
  365.                         XtPointer clientData,
  366.                         XtPointer callData) ;
  367. extern void _XmTextResetClipOrigin( 
  368.                         XmTextWidget tw,
  369.                         XmTextPosition position,
  370. #if NeedWidePrototypes
  371.                         int clip_mask_reset) ;
  372. #else
  373.                         Boolean clip_mask_reset) ;
  374. #endif /* NeedWidePrototypes */
  375. extern void _XmTextAdjustGC( 
  376.                         XmTextWidget tw) ;
  377. extern Boolean _XmTextShouldWordWrap( 
  378.                         XmTextWidget widget) ;
  379. extern Boolean _XmTextScrollable( 
  380.                         XmTextWidget widget) ;
  381. extern XmTextPosition _XmTextFindLineEnd( 
  382.                         XmTextWidget widget,
  383.                         XmTextPosition position,
  384.                         LineTableExtra *extra) ;
  385. extern void _XmTextOutputGetSecResData( 
  386.                         XmSecondaryResourceData *secResDataRtn) ;
  387. extern int _XmTextGetNumberLines( 
  388.                         XmTextWidget widget) ;
  389. extern void _XmTextMovingCursorPosition( 
  390.                         XmTextWidget tw,
  391.                         XmTextPosition position) ;
  392. extern void _XmTextDrawDestination( 
  393.                         XmTextWidget widget) ;
  394. extern void _XmTextClearDestination( 
  395.                         XmTextWidget widget,
  396. #if NeedWidePrototypes
  397.                         int ignore_sens) ;
  398. #else
  399.                         Boolean ignore_sens) ;
  400. #endif /* NeedWidePrototypes */
  401. extern void _XmTextDestinationVisible( 
  402.                         Widget w,
  403. #if NeedWidePrototypes
  404.                         int turn_on) ;
  405. #else
  406.                         Boolean turn_on) ;
  407. #endif /* NeedWidePrototypes */
  408. extern void _XmTextChangeBlinkBehavior( 
  409.                         XmTextWidget widget,
  410. #if NeedWidePrototypes
  411.                         int newvalue) ;
  412. #else
  413.                         Boolean newvalue) ;
  414. #endif /* NeedWidePrototypes */
  415. extern void _XmTextOutputCreate( 
  416.                         Widget wid,
  417.                         ArgList args,
  418.                         Cardinal num_args) ;
  419. extern Boolean _XmTextGetBaselines( 
  420.                         Widget widget,
  421.                         Dimension **baselines,
  422.                         int *line_count) ;
  423. extern Boolean _XmTextGetDisplayRect( 
  424.                         Widget w,
  425.                         XRectangle *display_rect) ;
  426. extern void _XmTextMarginsProc( 
  427.                         Widget w,
  428.                         XmBaselineMargins *margins_rec) ;
  429. extern void _XmTextChangeHOffset( 
  430.                         XmTextWidget widget,
  431.                         int length) ;
  432. extern void _XmTextToggleCursorGC( 
  433.                         Widget widget) ;
  434.  
  435. #endif /* _NO_PROTO */
  436. /********    End Private Function Declarations    ********/
  437.  
  438.  
  439.  
  440. #if defined(__cplusplus) || defined(c_plusplus)
  441. }  /* Close scope of 'extern "C"' declaration which encloses file. */
  442. #endif
  443.  
  444. #endif /* _XmTextOutP_h */
  445. /* DON'T ADD ANYTHING AFTER THIS #endif */
  446.